﻿@namespace MudBlazor
@using MudBlazor.Resources
@inherits MudComponentBase
@inject InternalMudLocalizer Localizer

<MudToolBar @attributes="UserAttributes" Class="@Classname" Style="@Style">
    @if (HorizontalAlignment == HorizontalAlignment.End ||
   (HorizontalAlignment == HorizontalAlignment.Right && !RightToLeft) ||
   (HorizontalAlignment == HorizontalAlignment.Left && RightToLeft) ||
    HorizontalAlignment == HorizontalAlignment.Center)
    {
        <div class="mud-table-pagination-spacer"></div>
    }
    @if (!HideRowsPerPage)
    {
        <div class="@PaginationClassname">
            <div class="mud-table-pagination-caption">
                <div class="mud-table-pagination-information">@RowsPerPageString</div>
            </div>
            <CascadingValue Name="SubscribeToParentForm" Value="false" IsFixed>
                <MudSelect T="int" ValueChanged="SetRowsPerPage" Value="@(Table?.RowsPerPage ?? 0)" Class="mud-table-pagination-select" Underline="false" Dense="true">
                    @foreach (int pageSize in PageSizeOptions)
                    {
                        if (pageSize == int.MaxValue)
                        {
                            <MudSelectItem T="int" Value="@pageSize">@AllItemsText</MudSelectItem>
                        }
                        else
                        {
                            <MudSelectItem T="int" Value="@pageSize">@pageSize.ToString().ToUpper()</MudSelectItem>
                        }
                    }
                </MudSelect>
            </CascadingValue>
        </div>
    }
    @if (!HidePageNumber)
    {
        <div class="mud-table-pagination-caption">
            <div class="mud-table-page-number-information">@Info</div>
        </div>
    }
    @if (!HidePagination)
    {
        <div class="mud-table-pagination-actions">
            <MudIconButton Class="mud-flip-x-rtl mud-table-pagination-first-button" Icon="@FirstIcon" Disabled="@BackButtonsDisabled" @onclick="@(() => Table?.NavigateTo(Page.First))" aria-label="@Localizer[LanguageResource.MudTablePager_FirstPage]" />
            <MudIconButton Class="mud-flip-x-rtl mud-table-pagination-before-button" Icon="@BeforeIcon" Disabled="@BackButtonsDisabled" @onclick="@(() => Table?.NavigateTo(Page.Previous))" aria-label="@Localizer[LanguageResource.MudTablePager_PreviousPage]" />
            <MudIconButton Class="mud-flip-x-rtl mud-table-pagination-next-button" Icon="@NextIcon" Disabled="@ForwardButtonsDisabled" @onclick="@(() => Table?.NavigateTo(Page.Next))" aria-label="@Localizer[LanguageResource.MudTablePager_NextPage]" />
            <MudIconButton Class="mud-flip-x-rtl mud-table-pagination-last-button" Icon="@LastIcon" Disabled="@ForwardButtonsDisabled" @onclick="@(() => Table?.NavigateTo(Page.Last))" aria-label="@Localizer[LanguageResource.MudTablePager_LastPage]" />
        </div>
    }
    @if (HorizontalAlignment == HorizontalAlignment.Start ||
 (HorizontalAlignment == HorizontalAlignment.Left && !RightToLeft) ||
 (HorizontalAlignment == HorizontalAlignment.Right && RightToLeft) ||
  HorizontalAlignment == HorizontalAlignment.Center)
    {
        <div class="mud-table-pagination-spacer"></div>
    }
</MudToolBar>

